package com.claude.communication;

import android.content.Context;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class RequestManager {
	static private RequestManager mInstance = null;
	
	public static RequestManager newInstance(){
		if(mInstance == null){
			synchronized(RequestManager.class){
				if(mInstance == null){
					mInstance = new RequestManager();
					return mInstance;
				}
			}
		}
		return mInstance;
	}
	
	private RequestQueue mQueue = null;
	private Context mContext = null;
	
	public void init(Context context){
		this.mContext = context;
		this.mQueue = Volley.newRequestQueue(this.mContext);
	}
	
	private RequestManager(){
	}
	
	public void addRequest(RequestNode requestNode){
		this.mQueue.add(requestNode.getJsonObjectRequest());
	}
	
	public void startRequest(){
		this.mQueue.start();
	}
	
	public void stopRequest(){
		this.mQueue.stop();
	}
}
